<template>
  <section class="wrapper">
    <myHeader :obj="myObj" @events="events"></myHeader>
    <main>
      <div class="titles_0314">话题标题（30字以内）</div>
      <div class="text_0314"><label class="label">标题</label><input placeholder="预设内容" type="text"></div>
      <div class="titles_0314">话题描述（20-300字）</div>
      <div class="textarea_0314"><textarea placeholder="内容描述">资本市场是中国经济实现转型的基石，无论是在产业升级、经济转型，还是在过去的破旧立新等方面，甚至在去杠杆角度，私募股权投资起到的作用不可替代。</textarea></div>
      <div class="titles_0314">添加图片</div>
      <div class="imgsWrap_0314">
        <span class="imgItem_0314 red"></span>
        <span class="imgItem_0314 red"></span>
        <span class="imgItem_0314 red"></span>
        <span class="imgItem_0314 red"></span>
        <span class="imgItem_0314 red"></span>
        <span class="imgItem_0314 red"></span>
        <span class="imgItem_0314 red"></span>
        <span class="imgItem_0314 red"></span>
        <span class="imgItem_0314 addImg_0314"></span>
      </div>
      <div class="titles_0314 other_0314">适合哪类人群（1-6个）</div>
      <div class="labels_0314">
        <span class="label">XML</span>
        <span class="label">XHTML</span>
        <span class="label">诺基亚</span>
        <span class="addLabel">添加标签+</span>
      </div>
      <div class="titles_0314 other_0314">约见模式</div>
      <div class="meetType_0314">
        <span class="meetItem_0314 meetActive_0314">一对一</span>
        <span class="meetItem_0314">一对多（最多4人）</span>
      </div>
      <div class="items_0314">
        <label class="itLabels_0314">选择地点</label>
        <input class="itInput_0314" type="text">
        <i class="icons2_0314 noIcon2_0316"></i>
      </div>
      <div @click="open('picker1')" class="items_0314">
        <label class="itLabels_0314">约见时间</label>
        <div class="itInput_0314">{{timeStr}}</div>
        <i class="icons2_0314"></i>
      </div>
      <div class="items_0314">
        <label class="itLabels_0314">约见金额</label>
        <input class="itInput_0314" type="number" placeholder="300.00">
        <i class="icons2_0314 noIcon2_0316"></i>
      </div>
      <button class="sends_0314">提交</button>

      <!-- 不需要管的html代码 -->
      <mt-datetime-picker  id="add_0314"
        ref="picker1"
        type="date"
        v-model="value1"
        year-format="{value} 年"
        month-format="{value} 月"
        date-format="{value} 日"
        :startDate="startDate"
        :endDate="endDate"
        @confirm="handleChange_1">
      </mt-datetime-picker>
      <mt-datetime-picker id="add_0314_2"
        ref="picker2"
        type="time"
        @confirm="handleChange_2">
      </mt-datetime-picker>
      <mt-datetime-picker id="add_0314_3"
        ref="picker3"
        type="time"
        @confirm="handleChange_3">
      </mt-datetime-picker>
    </main>

  </section>
</template>
<script>
import myHeader from './base/myHeader';
import { DatetimePicker } from 'mint-ui';
import Vue from 'vue';
export default {
  data () {
    return {
      myObj: {
        type: 4,
        text: '话题修改'
      },
      existArr: {
        date1: false,
        date2: false,
        date3: false,
      },
      value: null,
      value1: null,
      value2: null,
      startDate: new Date(),
      endDate: new Date('2048-12-31'),
      timeStr: '',
    }
  },
  methods: {
    events(i){
      if(i == 2) {
        history.back();
      }
    },
    changeStatus(str, status) {
      this.popup[str] = status;
    },

    //- 不需要管的代码 --------------------
    //------------------------------------
    //------------------------------------
    addEle(){
      if(!this.existArr.date1){
        let wrap = document.getElementById('add_0314');
        this.base(wrap,'开始时间','date1')
      }
      if(!this.existArr.date2) {
        let wrap2 = document.getElementById('add_0314_2');
        this.base(wrap2,'开始时间','date2')
      }
      if(!this.existArr.date3) {
        let wrap3 = document.getElementById('add_0314_3');
        this.base(wrap3,'结束时间','date3')
      }
    },
    base(wrap, str, status) {
      if(wrap){
        let picker = wrap.getElementsByClassName('picker')[0];
        let newItem = document.createElement("div");
        newItem.setAttribute('class', 'dateTitle_0316');
        newItem.innerHTML = str;
        picker.insertBefore(newItem,picker.childNodes[1]);
        this.existArr[status] = true;
      }
    },
    open(picker) {
      this.$refs[picker].open();
      this.addEle();
    },
    handleChange_1(value) {
      let year = value.getFullYear();
      let month = value.getMonth()+1;
      let day = value.getDate();
      if(month <= 9) {
        month = 0+''+month;
      }
      if(day<=9) {
        day = 0+''+day;
      }
      this.timeStr = year+'-'+month+'-'+day+' ';
      this.open('picker2');
    },
    handleChange_2(value){
      this.timeStr +=value;
      this.open('picker3');
    },
    handleChange_3(value){
      this.timeStr += "-"+value;
    },
    //- 不需要管的代码 --------------------
    //------------------------------------
    //------------------------------------
    
  },
  components: {
    myHeader,
    DatetimePicker
  }
}

</script>
<style lang="less">
  .wrapper {
    width: 3.75rem;
    height: 100%;
    main {
      width: 100%;
      height: 100%;
      padding-top: .44rem;
      position: absolute;
      top: 0;
      left: 0;
      overflow-y: auto;
      box-sizing: border-box;
      .dateTitle_0316 {
        height: .3rem;
        line-height: .3rem;
        text-align: center;
        font-size: .16rem;

      }
      .sends_0314 {
        display: block;
        width: 3.35rem;
        height: .47rem;
        border-radius: .05rem;
        background: #557AFF;
        border: none;
        color: white;
        font-size: .18rem;
        margin: .4rem auto;
      }
      .items_0314 {
        background: white;
        width: 100%;
        height: .44rem;
        padding: 0 .15rem;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: .01rem solid #E5E5E5;
        &:nth-last-of-type(1) {
          border:none;
        }
        .icons2_0314 {
          display: block;
          width: .2rem;
          height: .2rem;
          background: url('../assets/img/icon_shape@3x.png') center center;
          background-size: cover;
          background-repeat: no-repeat;
        }
        .noIcon2_0316 {
           background: none!important;
        }
        .itInput_0314 {
          width: 2.2rem;
          height: .43rem;
          line-height: .43rem;
          color: #B2B2B2;
          font-size: .17rem;
          border: none;
        }
        .itLabels_0314 {
          display: block;
          width: .9rem;
          height: .44rem;
          line-height: .44rem;
          font-size: .17rem;
          font-weight: 500;
          color: #000;
        }
      }
      .meetType_0314 {
        padding: 0 .15rem .35rem;
        overflow: hidden;
        .meetItem_0314 {
          display: block;
          height: .3rem;
          line-height: .3rem;
          padding: 0 .2rem;
          font-size: .14rem;
          background: #828282;
          color: white;
          float: left;
          border-radius: .04rem;
          margin-right: .19rem;

        }
        .meetActive_0314 {
          background: #39393D;
        }

      }
      .labels_0314 {
        overflow: hidden;
        padding: 0 .2rem 0;
        span {
          display: block;
          float: left;
          text-align: center;
          padding: .07rem .1rem;
          margin: 0 .14rem .14rem 0;
          border: .04rem;
          border-radius: .04rem;
          font-size: .14rem;
          &.addLabel{
            background: #39393D;
            color: white;
          }
          &.label{
            background: blue;
            color: white;
          }
        }
        
      }
      .imgsWrap_0314 {
        padding: .15rem .15rem 0 .15rem;
        background: white;
        overflow: hidden;
        .imgItem_0314 {
          width: .58rem;
          height: .58rem;
          display: block;
          float: left;
          margin-right: .13rem;
          margin-bottom: .13rem;
          &:nth-of-type(5n) {
            margin-right: 0rem;
          }
        }
        .red {
          background: #ccc!important;
        }
        .addImg_0314 {
          background: url('../assets/img/expert/icon_ba@3x.png') center center;
          background-size: cover;
          background-repeat: no-repeat;
        }
      }
      .textarea_0314 {
        width: 100%;
        padding: .11rem .15rem;
        background: white;
        box-sizing: border-box;
        textarea{
          width: 100%;
          min-height: .53rem;
          font-size: .14rem;
          color: #B2B2B2;
          font-family: "Microsoft YaHei";
        }
      }
      .other_0314 {
        color: #353535!important;
      }
      .titles_0314 {
        width: 100%;
        height: .4rem;
        line-height: .4rem;
        padding-left: .15rem;
        box-sizing: border-box;
        font-size: .14rem;
        color: #888888;

      }
      .text_0314 {
        height: .44rem;
        padding: 0 .15rem;
        background: white;
        display: flex;
        align-items: center;
        .label {
          width: .9rem;
          font-size: .17rem;
          color: #000;
          font-weight: bold;
        }
        input {
          display: flex;
          flex: 1;
          color: #B2B2B2;
          font-size: .17rem;
          border: none;
        }
      }
    }
  }
  
</style>
